package com.kaibes.module.theme;

import java.util.List;

import org.springframework.stereotype.Service;

import com.kaibes.orm.curd.QueryBuilder;
import com.kaibes.web.api.ResponseServiceImpl;

@Service
public class ThemeService extends ResponseServiceImpl<Theme> {
    
    public List<Theme> listActiveTheme() {
        return list(QueryBuilder.newBuilder().eq("enable", true).build());
    }
    
    public Theme getByPath(String path) {
        return get(QueryBuilder.newBuilder().eq("path", path).build());
    }
    
    public Theme getByUriButNotPath(String uri, String path) {
        return get(QueryBuilder.newBuilder().eq("uri", uri).ne("path", path).build());
    }
    
    public int updateByPath(Theme e) {
        return super.update(e, QueryBuilder.newBuilder().eq("path", e.getPath()).build());
    }
    
    public Theme getByActiveTrue(String uri) {
        return get(QueryBuilder.newBuilder().eq("uri", uri).eq("enable", true).build());
    }
    
    public boolean removeByPath(String path) {
        return remove(QueryBuilder.newBuilder().eq("path", path).build())>0;
    }
    
}
